import cgi
from google.appengine.ext import db
from google.appengine.ext import webapp
from google.appengine.api import users
from entities import *
from Entities import *


def Add(avatar,userID):
    try:
        user = User.get_by_id(userID)
        if avatar != "":
            Ava = db.Blob(avatar)
        customer = Customer(Avatar = Ava,UserID = user)
        customer.put()
        return 1
    except:
        return 0
    
def Update(customerID,avatar):
    customer_update = Customer.get_by_id(customerID)
    customer_update.Avatar = avatar
    customer_update.put()
    return "Complete"
    
def Delete(customerID):
    customer = Customer.get_by_id(customerID)
    if customer.count() > 0:
        Customer.delete(customer)
        return "Complete"
    else:
        return "No ..."